package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class Test3 {
    public static void main(String[] args) throws Exception {
        Class clas = Class.forName("reflect.Person");
        Constructor constructor = clas.getConstructor(String.class);
        Object obj = constructor.newInstance("张三");
        Method[] method = clas.getDeclaredMethods();

        for (Method m :method){
            boolean mark = m.isAnnotationPresent(AutoRunMethod.class);
            if (mark){
                System.out.println(m.getName()+"()方法被标注了");
                m.invoke(obj);
            }else {
                System.out.println(m.getName()+"()方法没有被标注");
            }
        }

    }
}
